package com.moogene.android.engine.animlite;

import android.graphics.ColorMatrixColorFilter;
import android.util.Log;

public class ColorMatrixAnim extends Anime {
	private String TAG = "ColorMatrixFilterAnim";

	private final static float[] SEL_EFFECT_COLOR_MATRIX_LIGHTER = { 1, 0, 0,
			0, 60, 0, 1, 0, 0, 60, 0, 0, 1, 0, 60, 0, 0, 0, 1, 0 };
	private final static float[] SEL_EFFECT_COLOR_MATRIX_DARKER = { 1, 0, 0, 0,
			-60, 0, 1, 0, 0, -60, 0, 0, 1, 0, -60, 0, 0, 0, 1, 0 };

	private static ColorMatrixColorFilter[] sLightEffectCMCFilter;

	static {
		sLightEffectCMCFilter = new ColorMatrixColorFilter[2];
		sLightEffectCMCFilter[0] = new ColorMatrixColorFilter(
				SEL_EFFECT_COLOR_MATRIX_DARKER);
		sLightEffectCMCFilter[1] = new ColorMatrixColorFilter(
				SEL_EFFECT_COLOR_MATRIX_LIGHTER);
	}

	ColorMatrixAnim(DrawableWrapper drawableWrapper) {
        super(drawableWrapper);
    }

	public void start(ColorMatrixColorFilter colorMatrixColorFilter) {
		start();
		drawableWrapper.setColorFilter(colorMatrixColorFilter);
	}

	public void start(int lightLevel) {
		if (lightLevel > 1 || lightLevel < -1) {
			Log.d(TAG, "start(int lightLevel); Argument > 1 or < -1");
			throw new IllegalArgumentException();
		}
		switch (lightLevel) {
		case 1:
			start(sLightEffectCMCFilter[1]);
			break;
		case 0:
			stop();
			break;
		case -1:
			start(sLightEffectCMCFilter[0]);
			break;
		}
	}

	@Override
	public void stop() {
		super.stop();
		drawableWrapper.setColorFilter(null);
	}

	@Override
	boolean nextFrame() {
		return false;
	}

}
